<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>blmc_drivers: /workspace/software/workspace/src/catkin/hardware/blmc_drivers/demos/pd_control.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">blmc_drivers
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('pd__control_8hpp_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">pd_control.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="pd__control_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="motor_8hpp.html">blmc_drivers/devices/motor.hpp</a>&quot;</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="analog__sensor_8hpp.html">blmc_drivers/devices/analog_sensor.hpp</a>&quot;</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceblmc__drivers.html">blmc_drivers</a>{</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="keyword">typedef</span> std::shared_ptr&lt;blmc_drivers::SafeMotor&gt; <a class="code" href="namespaceblmc__drivers.html#ab975c3be3c53a93a10c491f07a132e2b">SafeMotor_ptr</a>;</div><div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="namespaceblmc__drivers.html#a1eb492ab42b913d5bcc21d53ba7185ba">   24</a></span>&#160;<span class="keyword">typedef</span> std::shared_ptr&lt;blmc_drivers::AnalogSensor&gt; <a class="code" href="namespaceblmc__drivers.html#a1eb492ab42b913d5bcc21d53ba7185ba">Slider_ptr</a>;</div><div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="namespaceblmc__drivers.html#a134270c90d29a9a28b64ab0e5f7158f7">   28</a></span>&#160;<span class="keyword">typedef</span> std::pair&lt;SafeMotor_ptr, Slider_ptr&gt; <a class="code" href="namespaceblmc__drivers.html#a134270c90d29a9a28b64ab0e5f7158f7">PairMotorSlider</a>;</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div><div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="classblmc__drivers_1_1PDController.html">   33</a></span>&#160;<span class="keyword">class </span><a class="code" href="classblmc__drivers_1_1PDController.html">PDController</a></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;{</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="classblmc__drivers_1_1PDController.html#a78e3d01f6bcc263b20b81a7525d072cf">   41</a></span>&#160;  <a class="code" href="classblmc__drivers_1_1PDController.html#a78e3d01f6bcc263b20b81a7525d072cf">PDController</a>(std::vector&lt;PairMotorSlider&gt; motor_slider_pairs):</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    motor_slider_pairs_(motor_slider_pairs)</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;  {</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    stop_loop=<span class="keyword">false</span>;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  }</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="classblmc__drivers_1_1PDController.html#aed8ffc7914eb5976f95936315bcd9c47">   50</a></span>&#160;  <a class="code" href="classblmc__drivers_1_1PDController.html#aed8ffc7914eb5976f95936315bcd9c47">~PDController</a>()</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;  {</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    stop_loop=<span class="keyword">true</span>;</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;    rt_thread_.join();</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;  }</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div><div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="classblmc__drivers_1_1PDController.html#a9c9258e9f1af0f4ca00d2ede682ad511">   59</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classblmc__drivers_1_1PDController.html#a9c9258e9f1af0f4ca00d2ede682ad511">start_loop</a>()</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  {</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    rt_thread_.create_realtime_thread(&amp;PDController::loop, <span class="keyword">this</span>);</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;  }</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;  std::vector&lt;PairMotorSlider&gt; motor_slider_pairs_;</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;  real_time_tools::RealTimeThread rt_thread_;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;  <span class="keyword">static</span> THREAD_FUNCTION_RETURN_TYPE loop(<span class="keywordtype">void</span>* instance_pointer)</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;  {</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    ((<a class="code" href="classblmc__drivers_1_1PDController.html">PDController</a>*)(instance_pointer))-&gt;loop();</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <span class="keywordflow">return</span> THREAD_FUNCTION_RETURN_VALUE;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  }</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;  <span class="keywordtype">void</span> loop();</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;  <span class="keywordtype">bool</span> stop_loop;</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;}; <span class="comment">// end class PDController definition</span></div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;}<span class="comment">// namespace blmc_drivers</span></div><div class="ttc" id="classblmc__drivers_1_1PDController_html_a9c9258e9f1af0f4ca00d2ede682ad511"><div class="ttname"><a href="classblmc__drivers_1_1PDController.html#a9c9258e9f1af0f4ca00d2ede682ad511">blmc_drivers::PDController::start_loop</a></div><div class="ttdeci">void start_loop()</div><div class="ttdoc">This method is a helper to start the thread loop. </div><div class="ttdef"><b>Definition:</b> pd_control.hpp:59</div></div>
<div class="ttc" id="classblmc__drivers_1_1PDController_html_aed8ffc7914eb5976f95936315bcd9c47"><div class="ttname"><a href="classblmc__drivers_1_1PDController.html#aed8ffc7914eb5976f95936315bcd9c47">blmc_drivers::PDController::~PDController</a></div><div class="ttdeci">~PDController()</div><div class="ttdoc">Destroy the PDController object. </div><div class="ttdef"><b>Definition:</b> pd_control.hpp:50</div></div>
<div class="ttc" id="classblmc__drivers_1_1PDController_html_a78e3d01f6bcc263b20b81a7525d072cf"><div class="ttname"><a href="classblmc__drivers_1_1PDController.html#a78e3d01f6bcc263b20b81a7525d072cf">blmc_drivers::PDController::PDController</a></div><div class="ttdeci">PDController(std::vector&lt; PairMotorSlider &gt; motor_slider_pairs)</div><div class="ttdoc">Construct a new PDController object. </div><div class="ttdef"><b>Definition:</b> pd_control.hpp:41</div></div>
<div class="ttc" id="namespaceblmc__drivers_html"><div class="ttname"><a href="namespaceblmc__drivers.html">blmc_drivers</a></div><div class="ttdoc">This namespace is the standard namespace of the package. </div><div class="ttdef"><b>Definition:</b> analog_sensors.cpp:15</div></div>
<div class="ttc" id="classblmc__drivers_1_1PDController_html"><div class="ttname"><a href="classblmc__drivers_1_1PDController.html">blmc_drivers::PDController</a></div><div class="ttdoc">This is a basic PD controller to be used in the demos of this package. </div><div class="ttdef"><b>Definition:</b> pd_control.hpp:33</div></div>
<div class="ttc" id="namespaceblmc__drivers_html_a134270c90d29a9a28b64ab0e5f7158f7"><div class="ttname"><a href="namespaceblmc__drivers.html#a134270c90d29a9a28b64ab0e5f7158f7">blmc_drivers::PairMotorSlider</a></div><div class="ttdeci">std::pair&lt; SafeMotor_ptr, Slider_ptr &gt; PairMotorSlider</div><div class="ttdoc">This is a simple shortcut. </div><div class="ttdef"><b>Definition:</b> pd_control.hpp:28</div></div>
<div class="ttc" id="namespaceblmc__drivers_html_a1eb492ab42b913d5bcc21d53ba7185ba"><div class="ttname"><a href="namespaceblmc__drivers.html#a1eb492ab42b913d5bcc21d53ba7185ba">blmc_drivers::Slider_ptr</a></div><div class="ttdeci">std::shared_ptr&lt; blmc_drivers::AnalogSensor &gt; Slider_ptr</div><div class="ttdoc">This is a simple shortcut. </div><div class="ttdef"><b>Definition:</b> pd_control.hpp:24</div></div>
<div class="ttc" id="analog__sensor_8hpp_html"><div class="ttname"><a href="analog__sensor_8hpp.html">analog_sensor.hpp</a></div><div class="ttdoc">License BSD-3-Clause </div></div>
<div class="ttc" id="motor_8hpp_html"><div class="ttname"><a href="motor_8hpp.html">motor.hpp</a></div><div class="ttdoc">License BSD-3-Clause </div></div>
<div class="ttc" id="namespaceblmc__drivers_html_ab975c3be3c53a93a10c491f07a132e2b"><div class="ttname"><a href="namespaceblmc__drivers.html#ab975c3be3c53a93a10c491f07a132e2b">blmc_drivers::SafeMotor_ptr</a></div><div class="ttdeci">std::shared_ptr&lt; blmc_drivers::SafeMotor &gt; SafeMotor_ptr</div><div class="ttdoc">This is a simple shortcut. </div><div class="ttdef"><b>Definition:</b> const_torque_control.hpp:20</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_80e6cdd9bbc895bd262b4f65e652822c.html">catkin</a></li><li class="navelem"><a class="el" href="dir_dace45749abc688185d44e8b166728a5.html">hardware</a></li><li class="navelem"><a class="el" href="dir_87d2711f33d814f4f77c208b3c1f3ba9.html">blmc_drivers</a></li><li class="navelem"><a class="el" href="dir_293b3db1cc079afe618c903d28d185a2.html">demos</a></li><li class="navelem"><a class="el" href="pd__control_8hpp.html">pd_control.hpp</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
